package com.iut.sujet2.presentation;

import java.net.URL;
import java.util.ResourceBundle;


import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.shape.Rectangle;

public class DrawFrame implements Initializable {

	public DrawFrame() {
		// TODO Auto-generated constructor stub
	}

	
	@FXML private Canvas c_drawZone;
	@FXML private Button b_reset;
	@FXML private Rectangle r_zone;
	private GraphicsContext gc;
	public void initialize(URL arg0, ResourceBundle arg1) {
		
		MainFrame.df = this;
		
		gc = c_drawZone.getGraphicsContext2D();
		
		c_drawZone.setOnMousePressed(new EventHandler<MouseEvent>() {

			public void handle(MouseEvent arg0) {
				
				gc.fillOval(arg0.getX()-5, arg0.getY()-5, 10, 10);
				
				//gc.fillOval(arg0.getSceneX(), arg0.getSceneY()-c_drawZone.getLayoutY()-25, 10, 10);
			}
		});
		
		b_reset.setOnAction(new EventHandler<ActionEvent>() {
			
			public void handle(ActionEvent arg0) {
				gc.clearRect(0, 0, c_drawZone.getWidth(),
                        c_drawZone.getHeight());
				
			}
		});
		
		
		
	}
	/**
	 * @return the c_drawZone
	 */
	public Canvas getC_drawZone() {
		return c_drawZone;
	}
	/**
	 * @return the b_reset
	 */
	public Button getB_reset() {
		return b_reset;
	}
	/**
	 * @return the r_zone
	 */
	public Rectangle getR_zone() {
		return r_zone;
	}
	/**
	 * @return the gc
	 */
	public GraphicsContext getGc() {
		return gc;
	}
	/**
	 * @param c_drawZone the c_drawZone to set
	 */
	public void setC_drawZone(Canvas c_drawZone) {
		this.c_drawZone = c_drawZone;
	}
	/**
	 * @param b_reset the b_reset to set
	 */
	public void setB_reset(Button b_reset) {
		this.b_reset = b_reset;
	}
	/**
	 * @param r_zone the r_zone to set
	 */
	public void setR_zone(Rectangle r_zone) {
		this.r_zone = r_zone;
	}
	/**
	 * @param gc the gc to set
	 */
	public void setGc(GraphicsContext gc) {
		this.gc = gc;
	}
	
	



}
